local difu = fk.CreateSkill {
  name = "th_difu",
}

difu:addEffect(fk.EventPhaseEnd, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(difu.name) then
      return player.phase == Player.Play
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = difu.name,
      prompt = "#th_difu-invoke"
    })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:skip(Player.Discard)
    player:turnOver()
  end
})
difu:addEffect(fk.TurnedOver, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(difu.name) then
      if event == fk.EventPhaseEnd then
        return player.phase == Player.Play
      elseif event == fk.TurnedOver then
        return true
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:drawCards(player.faceup and 1 or 2, difu.name)
  end
})

Fk:loadTranslationTable{
  ["th_difu"] = "地缚",
  [":th_difu"] = "出牌阶段结束时，你可以跳过弃牌阶段并翻面；当你翻面后，你摸一张牌，若翻至背面，多摸一张牌。",

  ["#th_difu-invoke"] = "地缚：你可以跳过弃牌阶段并翻面",
}

return difu